package com.mycompany.app.common.extjs.grid.web;

import java.io.ByteArrayInputStream;
import java.util.List;

import com.mycompany.app.common.audit.access.filter.dao.ILoggingMessageDao;
import com.mycompany.app.common.audit.access.filter.model.LoggingMessage;
import com.mycompany.app.common.extjs.ExtJSBaseAction;
import com.mycompany.app.common.extjs.ExtJSUtils;

@SuppressWarnings("serial")
public class GridAction extends ExtJSBaseAction {

    private ILoggingMessageDao loggingMessageDao;

    public void setLoggingMessageDao(ILoggingMessageDao loggingMessageDao) {

        this.loggingMessageDao = loggingMessageDao;
    }

    public String getAllLoggingMessage() {

        List<LoggingMessage> loggingMessages = loggingMessageDao.getAll();

        inputStream = new ByteArrayInputStream(ExtJSUtils.wrapJsonReader(
                objectList2json(loggingMessages).toString(),
                LoggingMessage.class, loggingMessages.size()).getBytes());
        return SUCCESS;
    }

    public static void main(String[] args) {

    }

    // Task:
    //
    // server return ROR JSONReader
    // Java List---->Json List---->JSonReaderWrapper

}
